<?php

class Avpt_Miolo_Destaque_1 extends WP_Widget {
	function __construct() {
		parent::__construct( 'Avpt_Miolo_Destaque_1', 'Avpt Miolo Destaque 1', array( 'description' => 'Destaque Miolo 1' ) );
	}
	
	function widget ( $args, $instance ) {
		extract($args, EXTR_SKIP);
		$title = empty ($instance['title']) ? '' : apply_filters( 'widget_title', $instance['title' ]);
		
		$img_url_1 = empty ($instance['img_url_1']) ? '' : apply_filters('img_url_1', $instance['img_url_1']);
		$img_link_1 = empty ($instance['img_link_1']) ? '' : apply_filters('img_link_1', $instance['img_link_1']);
		$img_text_1 = empty ($instance['img_text_1']) ? '' : apply_filters('img_text_1', $instance['img_text_1']);

		$img_url_2 = empty ($instance['img_url_2']) ? '' : apply_filters('img_url_2', $instance['img_url_2']);
		$img_link_2 = empty ($instance['img_link_2']) ? '' : apply_filters('img_link_2', $instance['img_link_2']);
		$img_text_2 = empty ($instance['img_text_2']) ? '' : apply_filters('img_text_2', $instance['img_text_2']);

		$img_url_3 = empty ($instance['img_url_3']) ? '' : apply_filters('img_url_3', $instance['img_url_3']);
		$img_link_3 = empty ($instance['img_link_3']) ? '' : apply_filters('img_link_3', $instance['img_link_3']);
		$img_text_3 = empty ($instance['img_text_3']) ? '' : apply_filters('img_text_3', $instance['img_text_3']);

		$img_url_4 = empty ($instance['img_url_4']) ? '' : apply_filters('img_url_4', $instance['img_url_4']);
		$img_link_4 = empty ($instance['img_link_4']) ? '' : apply_filters('img_link_4', $instance['img_link_4']);
		$img_text_4 = empty ($instance['img_text_4']) ? '' : apply_filters('img_text_4', $instance['img_text_4']);

		$img_url_5 = empty ($instance['img_url_5']) ? '' : apply_filters('img_url_5', $instance['img_url_5']);
		$img_link_5 = empty ($instance['img_link_5']) ? '' : apply_filters('img_link_5', $instance['img_link_5']);
		$img_text_5 = empty ($instance['img_text_5']) ? '' : apply_filters('img_text_5', $instance['img_text_5']);

		$img_url_6 = empty ($instance['img_url_6']) ? '' : apply_filters('img_url_6', $instance['img_url_6']);
		$img_link_6 = empty ($instance['img_link_6']) ? '' : apply_filters('img_link_6', $instance['img_link_6']);
		$img_text_6 = empty ($instance['img_text_6']) ? '' : apply_filters('img_text_6', $instance['img_text_6']);

		$img_url_7 = empty ($instance['img_url_7']) ? '' : apply_filters('img_url_7', $instance['img_url_7']);
		$img_link_7 = empty ($instance['img_link_7']) ? '' : apply_filters('img_link_7', $instance['img_link_7']);
		$img_text_7 = empty ($instance['img_text_7']) ? '' : apply_filters('img_text_7', $instance['img_text_7']);

		$img_url_8 = empty ($instance['img_url_8']) ? '' : apply_filters('img_url_8', $instance['img_url_8']);
		$img_link_8 = empty ($instance['img_link_8']) ? '' : apply_filters('img_link_8', $instance['img_link_8']);
		$img_text_8 = empty ($instance['img_text_8']) ? '' : apply_filters('img_text_8', $instance['img_text_8']);

		$img_url_9 = empty ($instance['img_url_9']) ? '' : apply_filters('img_url_9', $instance['img_url_9']);
		$img_link_9 = empty ($instance['img_link_9']) ? '' : apply_filters('img_link_9', $instance['img_link_9']);
		$img_text_9 = empty ($instance['img_text_9']) ? '' : apply_filters('img_text_9', $instance['img_text_9']);

		$img_url_10 = empty ($instance['img_url_10']) ? '' : apply_filters('img_url_10', $instance['img_url_10']);
		$img_link_10 = empty ($instance['img_link_10']) ? '' : apply_filters('img_link_10', $instance['img_link_10']);
		$img_text_10 = empty ($instance['img_text_10']) ? '' : apply_filters('img_text_10', $instance['img_text_10']);

			
		$up = empty ($instance['up']) ? '0' : apply_filters('up', $instance['up']);
		$down = empty ($instance['down']) ? '0' : apply_filters('down', $instance['down']); 

		$destaques = array( 
			'destaque1' => array( 'img_url_1' => $img_url_1, 'img_link_1' => $img_link_1, 'img_text_1' => $img_text_1 ), 
			'destaque2' => array( 'img_url_2' => $img_url_2, 'img_link_2' => $img_link_2, 'img_text_2' => $img_text_2 ), 
			'destaque3' => array( 'img_url_3' => $img_url_3, 'img_link_3' => $img_link_3, 'img_text_3' => $img_text_3 ),
			'destaque4' => array( 'img_url_4' => $img_url_4, 'img_link_4' => $img_link_4, 'img_text_4' => $img_text_4 ),
			'destaque5' => array( 'img_url_5' => $img_url_5, 'img_link_5' => $img_link_5, 'img_text_5' => $img_text_5 ),
			'destaque6' => array( 'img_url_6' => $img_url_6, 'img_link_6' => $img_link_6, 'img_text_6' => $img_text_6 ),
			'destaque7' => array( 'img_url_7' => $img_url_7, 'img_link_7' => $img_link_7, 'img_text_7' => $img_text_7 ),
			'destaque8' => array( 'img_url_8' => $img_url_8, 'img_link_8' => $img_link_8, 'img_text_8' => $img_text_8 ),
			'destaque9' => array( 'img_url_9' => $img_url_9, 'img_link_9' => $img_link_9, 'img_text_9' => $img_text_9 ),
			'destaque10' => array( 'img_url_10' => $img_url_10, 'img_link_10' => $img_link_10, 'img_text_10' => $img_text_10 ) 
			);
		?>
		<div class="<?php echo 'vertical_space_'.$up?>"></div>
		<div id="pub-carrossel-1" style="width:630px; margin-left:25px;">
			<script type="text/javascript">
			$(document).ready(function(){
			  $('.slider10').bxSlider({
			    slideWidth: 630,
			    minSlides: 1,
			    maxSlides: 1,
			    slideMargin: 5,
			    controls: false,
			    captions: true,
				pager: true
			  });
			});
			</script>			
			<div style="float:left;width:15px;height=100px;"></div>
			<div class="clr"></div>
			<span class="pub-retranca">DESTAQUES</span>
			<div class="vertical_space_2"></div>
			<div class="slider10">
				<?php
				$tam = count($destaques);
				for ($i=0; $i < $tam+1 ; $i++) { 
					if($destaques["destaque$i"]["img_url_$i"]=='') {
						// Do nothing
					} else { ?>
						<a href="<?php echo $destaques["destaque$i"]["img_link_$i"] ?>">
  							<img src="<?php echo $destaques["destaque$i"]["img_url_$i"] ?>" title="<?php echo $destaques["destaque$i"]["img_text_$i"] ?>" width="630px" height="300px" />
						</a>
					<?php
					}			
				}
				?>
			</div>
		</div>
		<div class="<?php echo 'vertical_space_'.$down?>"></div>		
	<?php	
	}
	
	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
		$instance['title'] = strip_tags( $new_instance['title'] );

		$instance['img_url_1'] = $new_instance['img_url_1'];
		$instance['img_link_1'] = $new_instance['img_link_1'];
		$instance['img_text_1'] = $new_instance['img_text_1'];

		$instance['img_url_2'] = $new_instance['img_url_2'];
		$instance['img_link_2'] = $new_instance['img_link_2'];
		$instance['img_text_2'] = $new_instance['img_text_2'];

		$instance['img_url_3'] = $new_instance['img_url_3'];
		$instance['img_link_3'] = $new_instance['img_link_3'];
		$instance['img_text_3'] = $new_instance['img_text_3'];

		$instance['img_url_4'] = $new_instance['img_url_4'];
		$instance['img_link_4'] = $new_instance['img_link_4'];
		$instance['img_text_4'] = $new_instance['img_text_4'];

		$instance['img_url_5'] = $new_instance['img_url_5'];
		$instance['img_link_5'] = $new_instance['img_link_5'];
		$instance['img_text_5'] = $new_instance['img_text_5'];

		$instance['img_url_6'] = $new_instance['img_url_6'];
		$instance['img_link_6'] = $new_instance['img_link_6'];
		$instance['img_text_6'] = $new_instance['img_text_6'];

		$instance['img_url_7'] = $new_instance['img_url_7'];
		$instance['img_link_7'] = $new_instance['img_link_7'];
		$instance['img_text_7'] = $new_instance['img_text_7'];

		$instance['img_url_8'] = $new_instance['img_url_8'];
		$instance['img_link_8'] = $new_instance['img_link_8'];
		$instance['img_text_8'] = $new_instance['img_text_8'];

		$instance['img_url_9'] = $new_instance['img_url_9'];
		$instance['img_link_9'] = $new_instance['img_link_9'];
		$instance['img_text_9'] = $new_instance['img_text_9'];

		$instance['img_url_10'] = $new_instance['img_url_10'];
		$instance['img_link_10'] = $new_instance['img_link_10'];
		$instance['img_text_10'] = $new_instance['img_text_10'];

		$instance['up'] = strip_tags($new_instance['up']);
		$instance['down'] = strip_tags($new_instance['down']);
		return $instance;
	}	
	
	function form ( $instance ) {
		require get_template_directory() . '/widget/widget-style.php';
		$instance = wp_parse_args((array) $instance, array( 
			'img_url_1' => '', 'img_link_1' => '', 'img_text_1' => '', 
			'img_url_2' => '', 'img_link_2' => '', 'img_text_2' => '',
			'img_url_3' => '', 'img_link_3' => '', 'img_text_3' => '',
			'img_url_4' => '', 'img_link_4' => '', 'img_text_4' => '',
			'img_url_5' => '', 'img_link_5' => '', 'img_text_5' => '',
			'img_url_6' => '', 'img_link_6' => '', 'img_text_6' => '',
			'img_url_7' => '', 'img_link_7' => '', 'img_text_7' => '',
			'img_url_8' => '', 'img_link_8' => '', 'img_text_8' => '',
			'img_url_9' => '', 'img_link_9' => '', 'img_text_9' => '',
			'img_url_10' => '', 'img_link_10' => '', 'img_text_10' => '',
			'up' => '', 'down' => '' )
			);
		$title = strip_tags($instance['title']);

		$img_url_1 = $instance['img_url_1'];
		$img_link_1 = $instance['img_link_1'];
		$img_text_1 = $instance['img_text_1'];

		$img_url_2 = $instance['img_url_2'];
		$img_link_2 = $instance['img_link_2'];
		$img_text_2 = $instance['img_text_2'];

		$img_url_3 = $instance['img_url_3'];
		$img_link_3 = $instance['img_link_3'];
		$img_text_3 = $instance['img_text_3'];

		$img_url_4 = $instance['img_url_4'];
		$img_link_4 = $instance['img_link_4'];
		$img_text_4 = $instance['img_text_4'];

		$img_url_5 = $instance['img_url_5'];
		$img_link_5 = $instance['img_link_5'];
		$img_text_5 = $instance['img_text_5'];

		$img_url_6 = $instance['img_url_6'];
		$img_link_6 = $instance['img_link_6'];
		$img_text_6 = $instance['img_text_6'];

		$img_url_7 = $instance['img_url_7'];
		$img_link_7 = $instance['img_link_7'];
		$img_text_7 = $instance['img_text_7'];

		$img_url_8 = $instance['img_url_8'];
		$img_link_8 = $instance['img_link_8'];
		$img_text_8 = $instance['img_text_8'];

		$img_url_9 = $instance['img_url_9'];
		$img_link_9 = $instance['img_link_9'];
		$img_text_9 = $instance['img_text_9'];

		$img_url_10 = $instance['img_url_10'];
		$img_link_10 = $instance['img_link_10'];
		$img_text_10 = $instance['img_text_10'];

		
		$up = strip_tags($instance['up']);
		$down = strip_tags($instance['down']);
		?>
		<p>
		  <label for="<?php echo $this->get_field_id('title');?>"><?php _e( 'Título: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>">
		  <span class="nota-input-box">Opcional</span>
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('up');?>"><?php _e('Espaço acima em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('up'); ?>" name="<?php echo $this->get_field_name('up'); ?>" value="<?php echo esc_attr($up); ?>">
		  <label for="<?php echo $this->get_field_id('down');?>"><?php _e('Espaço abaixo em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('down'); ?>" name="<?php echo $this->get_field_name('down'); ?>" value="<?php echo esc_attr($down); ?>">
		</p>
		<p>
		  <label for="<?php echo $this->get_field_id('img_url_1');?>"><?php _e( 'URL Imagem 1: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_1'); ?>" name="<?php echo $this->get_field_name('img_url_1'); ?>" value="<?php echo esc_attr($img_url_1); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_1');?>"><?php _e( 'Link da imagem 1: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_1'); ?>" name="<?php echo $this->get_field_name('img_link_1'); ?>" value="<?php echo esc_attr($img_link_1); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_1');?>"><?php _e( 'Texto da imagem 1: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_1'); ?>" name="<?php echo $this->get_field_name('img_text_1'); ?>" value="<?php echo esc_attr($img_text_1); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_2');?>"><?php _e( 'URL Imagem 2: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_2'); ?>" name="<?php echo $this->get_field_name('img_url_2'); ?>" value="<?php echo esc_attr($img_url_2); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_2');?>"><?php _e( 'Link da imagem 2: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_2'); ?>" name="<?php echo $this->get_field_name('img_link_2'); ?>" value="<?php echo esc_attr($img_link_2); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_2');?>"><?php _e( 'Texto da imagem 2: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_2'); ?>" name="<?php echo $this->get_field_name('img_text_2'); ?>" value="<?php echo esc_attr($img_text_2); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_3');?>"><?php _e( 'URL Imagem 3: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_3'); ?>" name="<?php echo $this->get_field_name('img_url_3'); ?>" value="<?php echo esc_attr($img_url_3); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_3');?>"><?php _e( 'Link da imagem 3: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_3'); ?>" name="<?php echo $this->get_field_name('img_link_3'); ?>" value="<?php echo esc_attr($img_link_3); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_3');?>"><?php _e( 'Texto da imagem 3: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_3'); ?>" name="<?php echo $this->get_field_name('img_text_3'); ?>" value="<?php echo esc_attr($img_text_3); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_4');?>"><?php _e( 'URL Imagem 4: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_4'); ?>" name="<?php echo $this->get_field_name('img_url_4'); ?>" value="<?php echo esc_attr($img_url_4); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_5');?>"><?php _e( 'Link da imagem 4: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_4'); ?>" name="<?php echo $this->get_field_name('img_link_4'); ?>" value="<?php echo esc_attr($img_link_4); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_6');?>"><?php _e( 'Texto da imagem 4: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_4'); ?>" name="<?php echo $this->get_field_name('img_text_4'); ?>" value="<?php echo esc_attr($img_text_4); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_5');?>"><?php _e( 'URL Imagem 5: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_5'); ?>" name="<?php echo $this->get_field_name('img_url_5'); ?>" value="<?php echo esc_attr($img_url_5); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_5');?>"><?php _e( 'Link da imagem 5: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_5'); ?>" name="<?php echo $this->get_field_name('img_link_5'); ?>" value="<?php echo esc_attr($img_link_5); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_5');?>"><?php _e( 'Texto da imagem 5: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_5'); ?>" name="<?php echo $this->get_field_name('img_text_5'); ?>" value="<?php echo esc_attr($img_text_5); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_6');?>"><?php _e( 'URL Imagem 6: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_6'); ?>" name="<?php echo $this->get_field_name('img_url_6'); ?>" value="<?php echo esc_attr($img_url_6); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_6');?>"><?php _e( 'Link da imagem 6: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_6'); ?>" name="<?php echo $this->get_field_name('img_link_6'); ?>" value="<?php echo esc_attr($img_link_6); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_6');?>"><?php _e( 'Texto da imagem 6: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_6'); ?>" name="<?php echo $this->get_field_name('img_text_6'); ?>" value="<?php echo esc_attr($img_text_6); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_7');?>"><?php _e( 'URL Imagem 7: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_7'); ?>" name="<?php echo $this->get_field_name('img_url_7'); ?>" value="<?php echo esc_attr($img_url_7); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_7');?>"><?php _e( 'Link da imagem 7: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_7'); ?>" name="<?php echo $this->get_field_name('img_link_7'); ?>" value="<?php echo esc_attr($img_link_7); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_7');?>"><?php _e( 'Texto da imagem 7: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_7'); ?>" name="<?php echo $this->get_field_name('img_text_7'); ?>" value="<?php echo esc_attr($img_text_7); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url8');?>"><?php _e( 'URL Imagem 8: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_8'); ?>" name="<?php echo $this->get_field_name('img_url_8'); ?>" value="<?php echo esc_attr($img_url_8); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_8');?>"><?php _e( 'Link da imagem 8: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_8'); ?>" name="<?php echo $this->get_field_name('img_link_8'); ?>" value="<?php echo esc_attr($img_link_8); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_8');?>"><?php _e( 'Texto da imagem 8: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_8'); ?>" name="<?php echo $this->get_field_name('img_text_8'); ?>" value="<?php echo esc_attr($img_text_8); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_9');?>"><?php _e( 'URL Imagem 9: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_9'); ?>" name="<?php echo $this->get_field_name('img_url_9'); ?>" value="<?php echo esc_attr($img_url_9); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_9');?>"><?php _e( 'Link da imagem 9: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_9'); ?>" name="<?php echo $this->get_field_name('img_link_9'); ?>" value="<?php echo esc_attr($img_link_9); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_9');?>"><?php _e( 'Texto da imagem 9: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_9'); ?>" name="<?php echo $this->get_field_name('img_text_9'); ?>" value="<?php echo esc_attr($img_text_9); ?>">
		</p>

		<p>
		  <label for="<?php echo $this->get_field_id('img_url_10');?>"><?php _e( 'URL Imagem 10: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_url_10'); ?>" name="<?php echo $this->get_field_name('img_url_10'); ?>" value="<?php echo esc_attr($img_url_10); ?>">
		  <label for="<?php echo $this->get_field_id('img_link_10');?>"><?php _e( 'Link da imagem 10: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_link_10'); ?>" name="<?php echo $this->get_field_name('img_link_10'); ?>" value="<?php echo esc_attr($img_link_10); ?>">
		  <label for="<?php echo $this->get_field_id('img_text_10');?>"><?php _e( 'Texto da imagem 10: ' ); ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('img_text_10'); ?>" name="<?php echo $this->get_field_name('img_text_10'); ?>" value="<?php echo esc_attr($img_text_10); ?>">
		</p>

	<?php
	}
}


// ========================================================================================================================================
// Bloco de notícias em destaque, mostra 2,3 ou 4 posts na vertical
// ========================================================================================================================================
class Avpt_Miolo_Destaque_2 extends WP_Widget { 

	function __construct(){
		parent::__construct('Avpt_Miolo_Destaque_2', 'Avpt Miolo Destaque 2', array('description' => 'Destaque Miolo 2'));
	}

	function widget($args, $instance) {
		include_once 'functions.php';
		extract($args, EXTR_SKIP);
		$title = empty ($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		$categoria = empty ($instance['categoria']) ? '' : apply_filters('categoria', $instance['categoria']);
		$categoria2 = empty ($instance['categoria2']) ? '' : apply_filters('categoria2', $instance['categoria2']);
		$link_mais = empty ($instance['link_mais']) ? '' : apply_filters('link_mais', $instance['link_mais']);
		$id_publicacao_1 = empty ($instance['id_publicacao_1']) ? '' : apply_filters('id_publicacao_1', $instance['id_publicacao_1']);
		$id_publicacao_2 = empty ($instance['id_publicacao_2']) ? '' : apply_filters('id_publicacao_2', $instance['id_publicacao_2']);
		$id_publicacao_3 = empty ($instance['id_publicacao_3']) ? '' : apply_filters('id_publicacao_3', $instance['id_publicacao_3']);
		$id_publicacao_4 = empty ($instance['id_publicacao_4']) ? '' : apply_filters('id_publicacao_4', $instance['id_publicacao_4']);
		$id_publicacao_5 = empty ($instance['id_publicacao_5']) ? '' : apply_filters('id_publicacao_5', $instance['id_publicacao_5']);
		$up = empty ($instance['up']) ? '15' : apply_filters('up', $instance['up']);
		$down = empty ($instance['down']) ? '15' : apply_filters('down', $instance['down']);
		$destaques = array($id_publicacao_1, $id_publicacao_2, $id_publicacao_3, $id_publicacao_4, $id_publicacao_5); ?>
		<div class="<?php echo 'vertical_space_'.$up?>"></div>
		<?php do_bloco_miolo_destaque_2 ($title, $link_mais, $categoria, $categoria2, $destaques);?>
		<div class="<?php echo 'vertical_space_'.$down ?>"></div>
	<?php
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['categoria'] = strip_tags($new_instance['categoria']);
		$instance['categoria2'] = strip_tags($new_instance['categoria2']);
		$instance['link_mais'] = $new_instance['link_mais'];
		$instance['id_publicacao_1'] = strip_tags($new_instance['id_publicacao_1']);
		$instance['id_publicacao_2'] = strip_tags($new_instance['id_publicacao_2']);
		$instance['id_publicacao_3'] = strip_tags($new_instance['id_publicacao_3']);
		$instance['id_publicacao_4'] = strip_tags($new_instance['id_publicacao_4']);
		$instance['id_publicacao_5'] = strip_tags($new_instance['id_publicacao_5']);
		$instance['up'] = strip_tags($new_instance['up']);
		$instance['down'] = strip_tags($new_instance['down']);
		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args((array) $instance, array('title' => '', 'categoria' => '', 'categoria2' => '', 
			'id_publicacao_1' => '', 'id_publicacao_2' => '', 'id_publicacao_3' => '', 'id_publicacao_4' => '', 
			'id_publicacao_4' => '', 'link_mais' => '', 'up' => '', 'down' => ''));
		$title = strip_tags($instance['title']);
		$categoria = strip_tags($instance['categoria']);
		$categoria2 = strip_tags($instance['categoria2']);
		$link_mais = $instance['link_mais'];
		$id_publicacao_1 = strip_tags($instance['id_publicacao_1']);
		$id_publicacao_2 = strip_tags($instance['id_publicacao_2']);
		$id_publicacao_3 = strip_tags($instance['id_publicacao_3']);
		$id_publicacao_4 = strip_tags($instance['id_publicacao_4']);
		$id_publicacao_5 = strip_tags($instance['id_publicacao_5']);
		$up = strip_tags($instance['up']);
		$down = strip_tags($instance['down']);
		?>
		<p>
		  <label for="<?php echo $this->get_field_id('title');?>"><?php _e('Título: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>">
		</p>
		<p>
		  <label><b>Por categoria:</b></label><br />	
		  <label for="<?php echo $this->get_field_id('categoria');?>"><?php _e('Categoria: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('categoria'); ?>" name="<?php echo $this->get_field_name('categoria'); ?>" value="<?php echo esc_attr($categoria); ?>">	
		  <label for="<?php echo $this->get_field_id('link_mais');?>"><?php _e('Link para ver mais: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('link_mais'); ?>" name="<?php echo $this->get_field_name('link_mais'); ?>" value="<?php echo esc_attr($link_mais); ?>">
		</p>
		<p>
		  <label><b>De forma aleatória por categoria:</b></label><br />
		  <label for="<?php echo $this->get_field_id('categoria2');?>"><?php _e('Categoria: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('categoria2'); ?>" name="<?php echo $this->get_field_name('categoria2'); ?>" value="<?php echo esc_attr($categoria2); ?>">	
		</p>

		<p>
		  <label><b>Por ID de publicação:</b></label><br />
		  <label for="<?php echo $this->get_field_id('id_publicacao_1');?>"><?php _e('Id da publicação 1: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('id_publicacao_1'); ?>" name="<?php echo $this->get_field_name('id_publicacao_1'); ?>" value="<?php echo esc_attr($id_publicacao_1); ?>">
		  <label for="<?php echo $this->get_field_id('id_publicacao_2');?>"><?php _e('Id da publicação 2: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('id_publicacao_2'); ?>" name="<?php echo $this->get_field_name('id_publicacao_2'); ?>" value="<?php echo esc_attr($id_publicacao_2); ?>">
		  <label for="<?php echo $this->get_field_id('id_publicacao_3');?>"><?php _e('Id da publicação 3: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('id_publicacao_3'); ?>" name="<?php echo $this->get_field_name('id_publicacao_3'); ?>" value="<?php echo esc_attr($id_publicacao_3); ?>">
		  <label for="<?php echo $this->get_field_id('id_publicacao_4');?>"><?php _e('Id da publicação 4: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('id_publicacao_4'); ?>" name="<?php echo $this->get_field_name('id_publicacao_4'); ?>" value="<?php echo esc_attr($id_publicacao_4); ?>">
		  <label for="<?php echo $this->get_field_id('id_publicacao_5');?>"><?php _e('Id da publicação 5: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('id_publicacao_5'); ?>" name="<?php echo $this->get_field_name('id_publicacao_5'); ?>" value="<?php echo esc_attr($id_publicacao_5); ?>">
		</p>

		<p>
		  <label><b>Espaçamento:</b></label><br />
		  <label for="<?php echo $this->get_field_id('up');?>"><?php _e('Espaço acima em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('up'); ?>" name="<?php echo $this->get_field_name('up'); ?>" value="<?php echo esc_attr($up); ?>">		
		  <label for="<?php echo $this->get_field_id('down');?>"><?php _e('Espaço abaixo em px: ') ?></label>
		  <input class="widefat" id="<?php echo $this->get_field_id('down'); ?>" name="<?php echo $this->get_field_name('down'); ?>" value="<?php echo esc_attr($down); ?>">		
		</p>
		<?php		
	}
}
// ========================================================================================================================================











